from urllib2 import Request, urlopen, URLError, HTTPError
import zipfile
import os

#url = 'http://scan-info.googlecode.com/files/network_scan.zip'
#fname = 'network_scan.zip'
url = 'http://nn-tools.googlecode.com/svn/trunk/backup.py'
fname = 'backup.py'
req = Request(url)

try:
    f = urlopen(req)
    print 'Downloading: {}'.format(fname)

    localFile = open(fname, 'wb')
    localFile.write(f.read())
    localFile.close()


except HTTPError as e:
    print 'Error 1'
    print e

except URLError as e:
    print 'Error 2'
    print e

except:
    print 'Oops, there was an error.'

else:
    print 'Download complete.'

"""
try:
    with zipfile.ZipFile(fname, 'r') as myzip:
        myzip.extractall()

    os.remove('network_scan.zip')
"""
except:
    print 'Oops, there was an error.'

else:
    print 'Update complete.'

print ''
print ''
raw_input('Press Enter to exit.')
        
